package domain;

public class Library implements IGeneralDomainObject {

	/*------------------------
	 * Library attributes
	 * ------------------------
	 */

	private int libraryID, borrowLength, maxNumExtending;
	private String libraryName, libraryAddress, libraryPhone, libraryEmail;

	private String searchCondition;
	
	public Library()
	{
		
	}

	public Library(int borrowLength, int maxNumExtending, String libraryName,
			String libraryAddress, String libraryPhone, String libraryEmail) {
		super();
		this.borrowLength = borrowLength;
		this.maxNumExtending = maxNumExtending;
		this.libraryName = libraryName;
		this.libraryAddress = libraryAddress;
		this.libraryPhone = libraryPhone;
		this.libraryEmail = libraryEmail;
	}

	public Library(int libraryID, int borrowLength, int maxNumExtending, String libraryName,
			String libraryAddress, String libraryPhone, String libraryEmail) {
		super();
		this.libraryID = libraryID;
		this.borrowLength = borrowLength;
		this.maxNumExtending = maxNumExtending;
		this.libraryName = libraryName;
		this.libraryAddress = libraryAddress;
		this.libraryPhone = libraryPhone;
		this.libraryEmail = libraryEmail;
	}

	/*------------------------
	 * attributes getters&setters
	 * -----------------------
	 */
	public int getLibraryID() {
		return libraryID;
	}

	public void setLibraryID(int libraryID) {
		this.libraryID = libraryID;
	}

	public int getBorrowLength() {
		return borrowLength;
	}

	public void setBorrowLength(int borrowLength) {
		if (borrowLength < -1)
			this.borrowLength = 1;
		else
			this.borrowLength = borrowLength;
	}

	public int getMaxNumExtending() {
		return maxNumExtending;
	}

	public void setMaxNumExtending(int maxNumExtending) {
		if (maxNumExtending < 0)
			maxNumExtending = 0;
		else
			this.maxNumExtending = maxNumExtending;
	}

	public String getLibraryName() {
		return libraryName;
	}

	public void setLibraryName(String libraryName) {
		this.libraryName = libraryName;
	}

	public String getLibraryAddress() {
		return libraryAddress;
	}

	public void setLibraryAddress(String libraryAddress) {
		this.libraryAddress = libraryAddress;
	}

	public String getLibraryPhone() {
		return libraryPhone;
	}

	public void setLibraryPhone(String libraryPhone) {
		this.libraryPhone = libraryPhone;
	}

	public String getLibraryEmail() {
		return libraryEmail;
	}

	public void setLibraryEmail(String libraryEmail) {
		this.libraryEmail = libraryEmail;
	}

	// -------------- END getters&setters ----------------- //

	/*
	 * -------------------------- IGeneralDomainObject implementation
	 * ---------------------------
	 */

	@Override
	public String getTableName() {
		return "TLibrary (libraryName,libraryAddress,libraryPhone,libraryEmail,borrowLength,maxNumExtending)";
	}

	@Override
	public String getUniqueCondition() {
		return null;
	}

	@Override
	public String getInsertValues() {
		return "'" + getLibraryName() + "','" + getLibraryAddress() + "','"
				+ getLibraryPhone() + "','" + getLibraryEmail() + "',"
				+ getBorrowLength() + "," + getMaxNumExtending();
	}

	// -------------- END IGeneralDomainObject implementation -----------------
	// //

	/*
	 * ---------------------------- Class specific search conditions
	 * ----------------------------
	 */
	public void searchByName() {
		searchCondition = "libraryName='" + getLibraryName() + "'";
	}

	public void searchByAdress() {
		searchCondition = "libraryAdress='" + getLibraryAddress() + "'";
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return libraryName;
	}

	@Override
	public String[] getColumnsNames() {
		// TODO Auto-generated method stub
		return new String[] {"libraryID", "borrowLength", "maxNumExtending", "libraryName", "libraryAddress", "libraryPhone", "libraryEmail"};
	}

	@Override
	public String getSimpleTableName() {
		// TODO Auto-generated method stub
		return "TLibrary";
	}

	@Override
	public String getFindValue() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getUpdateValue() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getDeleteValue() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getDeleteCondition() {
		// TODO Auto-generated method stub
		return null;
	}

}
